package com.shudes.game;

import java.util.*;

public class Dealer {
	
	public Dealer() {
	}
	
	public HoldemGame deal(Integer players, GameState state) { 
		HoldemGame game;
						
		game = new HoldemGame(players);
		game.getDeck().shuffle();
		
		dealHoleCards(game); 
		game.setBoard(dealBoard(game, state)); 
		
		return game;
	}
	
	protected Board dealBoard(HoldemGame game, GameState state) { 
		Collection<Card> cards; 
		
		cards = new ArrayList<Card>();
		for(int i=0;i<state.getNumberOfCards(); i++) { 
			cards.add(game.getDeck().deal()); 
		}
		
		return new Board(cards); 		
	}
	
	protected void dealPlayers(HoldemGame game) {
		for(int i=0; i<game.getNumberOfPlayers();i++) { 
			game.addHoleCards(new Seat(i), dealHoleCards(game)); 
		}
		
	}
	
	protected HoleCards dealHoleCards(HoldemGame game) { 
		return new HoleCards(game.getDeck().deal(), game.getDeck().deal()); 
	}
	
	

}
